package com.heima.article.service.impl;

import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.heima.article.mapper.ApArticleConfigMapper;
import com.heima.article.service.ApArticleConfigService;
import com.heima.model.article.pojos.ApArticleConfig;
import org.springframework.stereotype.Service;

import java.util.Map;

@Service
public class ApArticleConfigServiceImpl extends ServiceImpl<ApArticleConfigMapper, ApArticleConfig> implements ApArticleConfigService {
    @Override
    public void downOrUp(Map msgMap) {
        //取出消息的内容
        Long articleId = (Long) msgMap.get("articleId");
        Integer enable = (Integer) msgMap.get("enable");

        //更新文章的配置表，改变上下架状态
        UpdateWrapper<ApArticleConfig> updateWrapper = new UpdateWrapper<>();
        updateWrapper.eq("article_id",articleId);
        short isDown = enable==1?(short)0:(short)1;
        updateWrapper.set("is_down",isDown);
        update(updateWrapper);
    }
}
